package cn.easybuy.web.pre;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.alibaba.fastjson.JSON;

import cn.easybuy.entity.Car;
import cn.easybuy.service.CarService;
import cn.easybuy.service.impl.CarServiceImpl;

public class BuyCarServlet2 extends HttpServlet {

	@Override
	protected void service(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		response.setContentType("text/html;charset=utf-8");
		String opr = request.getParameter("opr");
		CarService carService = new CarServiceImpl();
		PrintWriter out = response.getWriter();
		Car car = new Car();
		if (opr.equals("showCar")) {
			List<Car> list = carService.getAllCarProduct();
			String carList = JSON.toJSONString(list);
			out.print(carList);

		} 

		out.flush();
		out.close();

	}
}
